using System;
using System.Collections.Generic;
using System.Text;

namespace IPSim.Data
{
    public class RIPPacket : IAppData
    {
        private RIPCommand m_ripCommand;
        private List<RIPNetInfo> m_netInfoList;
        private IPAddress m_srcIPAddr;

        public RIPPacket(RIPCommand cmd)
        {
            m_ripCommand = cmd;
            m_netInfoList = new List<RIPNetInfo>();
        }

        public void AddNetInfo(RIPNetInfo netInfo)
        {
            m_netInfoList.Add(netInfo);
        }

        public List<RIPNetInfo> NetInfoList
        {
            get
            {
                return m_netInfoList;
            }
        }

        public RIPCommand Command
        {
            get 
            {
                return m_ripCommand;
            }
        }


        public IPAddress SenderIPAddress
        {
            get
            {
                return m_srcIPAddr;
            }
            set
            {
                m_srcIPAddr = value;
            }
        }
    }

    public struct RIPTableEntry
    {
        private IPAddress m_nextHop;
        private byte m_metric;

        public RIPTableEntry(IPAddress hop, byte metric)
        {
            m_nextHop = hop;
            m_metric = metric;
        }

        public IPAddress NextHop
        {
            get
            {
                return m_nextHop;
            }
        }

        public byte Metric
        {
            get
            {
                return m_metric;
            }
        }
    }

    public struct RIPNetInfo
    {
        private readonly IPAddress m_ipAddress;
        private readonly byte m_metric;

        public RIPNetInfo(IPAddress ipAddr, byte metric)
        {
            m_ipAddress = ipAddr;
            m_metric = metric;
        }

        public IPAddress IPAddress
        {
            get
            {
                return m_ipAddress;
            }
        }

        public byte Metric
        {
            get
            {
                return m_metric;
            }
        }
    }


    public enum RIPCommand
    {
        Request,
        Response,
    }
}
